﻿using System.Globalization;
using DevPhone.Controls;
using Microsoft.Phone.Controls;

namespace DevPhoneToolkitSample.Samples
{
    public partial class UpDownControlSample : PhoneApplicationPage
    {
        private readonly string[] _valuelist = new[] { "Brazil", "France", "EUA", "Mexico", "Canada" };

        public UpDownControlSample()
        {
            InitializeComponent();
        }

        private void UpDn5UpDownValueChanged(object sender, UpDownCustomValueChangedEventArgs e)
        {
            e.CustomValue = e.NewValue.Equals(1) ? "On" : "Off";
        }

        private void UpDn6UpDownValueChanged(object sender, UpDownCustomValueChangedEventArgs e)
        {
            if (e.OldValue.Equals(0))
            {
                e.CustomText = " level";
                e.NewValue = 10;
                e.CustomValue = "10";
                return;
            }
            if (e.NewValue < 10)
            {
                e.CustomValue = "Off";
                e.NewValue = 0;
                e.CustomText = string.Empty;
                return;
            }

            e.CustomValue = e.NewValue.ToString(CultureInfo.InvariantCulture);
            e.CustomText = " level";
        }

        private void UpDn7UpDownValueChanged(object sender, UpDownCustomValueChangedEventArgs e)
        {
            e.CustomValue = _valuelist[(int)e.NewValue];
        }


    }
}